SWEP.Base = "weapon_ic_baseweapon"

if SERVER then
	AddCSLuaFile ("shared.lua")
end

SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true

SWEP.Spawnable				= true
SWEP.AdminSpawnable			= true

SWEP.PrintName			= "BENELLI M3"
SWEP.Description		= "A high-powered pump-action shotgun extremely effective at very low ranges or against tight groups of enemies."

SWEP.Slot					= 2
SWEP.Cost					= 2450
SWEP.IconFont				= "CSKillIcons"
SWEP.IconLetter				= "k"

SWEP.Primary.ClipSize		= 8
SWEP.Primary.DefaultClip	= 64
SWEP.Primary.Automatic		= true
SWEP.Primary.Ammo			= "smg1"

SWEP.Primary.Sound			= Sound ("Weapon_M3.Single")

SWEP.Primary.Delay			= 1.1
SWEP.Primary.Damage			= 30
SWEP.Primary.Cone			= 0.04
SWEP.Primary.Kick			= 7
SWEP.Primary.NumShots		= 9

SWEP.Secondary.ClipSize		= -1
SWEP.Secondary.DefaultClip	= -1
SWEP.Secondary.Automatic	= false 
SWEP.Secondary.Ammo			= "none"

SWEP.ReloadDelay = 0.3

SWEP.ViewModel = "models/weapons/v_shot_m3super90.mdl"
SWEP.ViewModelFlip = true
SWEP.ViewModelDefPos = Vector (4.9162, 0, -0.491)
SWEP.ViewModelDefAng = Vector (0.6111, -0.095, 0)

SWEP.WorldModel = "models/weapons/w_shot_m3super90.mdl"
SWEP.HoldType = "shotgun"

if CLIENT then killicon.AddFont("weapon_ic_m3", SWEP.IconFont, SWEP.IconLetter, Color(255, 80, 0, 255)) end

SWEP.IsShotgun	= true

SWEP.NextReload = 0
function SWEP:SetReloading(b)
	if self:GetReloading() == b then return end
	if b && self:FinishedReloading() then return end
	self:SetNWBool("reloading", b)
	
	if b then
		self.NextReload = CurTime() + self.ReloadDelay
	else
		self:SendWeaponAnim(ACT_SHOTGUN_RELOAD_FINISH)
		self:SetNextPrimaryFire(CurTime() + 1)
	end
end
function SWEP:GetReloading()
	return self:GetNWBool("reloading")
end
function SWEP:FinishedReloading()
	return self.Weapon:Clip1() >= self.Primary.ClipSize || self.Owner:GetAmmoCount(self.Primary.Ammo) <= 0
end
function SWEP:DoReload()
	if !self:GetReloading() then return end
	if CurTime() > self.NextReload then
		self.NextReload = CurTime() + self.ReloadDelay
		self:SetNextPrimaryFire(CurTime() + self.Primary.Delay)
		
		if self:FinishedReloading() then
			self:SetReloading(false)
		else
			if SERVER then
				self:SetClip1(self:Clip1() + 1)
				self.Owner:RemoveAmmo(1, self.Primary.Ammo, false)
			end
			self:SendWeaponAnim(ACT_VM_RELOAD)
		end
	end
end

function SWEP:Reload()
	self:SetReloading(true)
end
function SWEP:Think()
	self.BaseClass.Think(self)
	self:DoReload()
end
